package com.txy.mapper;

import com.itany.jdbc.util.RowMapper;
import com.txy.entity.Department;
import com.txy.entity.Employee;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Author：汤小洋
 * Date：2022-11-08 16:18
 * Description：<描述>
 */
public class EmployeeMapper implements RowMapper<Employee> {
    @Override
    public Employee mapRow(ResultSet rs) throws SQLException {
        Employee e = new Employee();
        e.setId(rs.getInt("id"));
        e.setName(rs.getString("name"));
        e.setAge(rs.getInt("age"));
        e.setSex(rs.getString("sex"));
        e.setHeight(rs.getDouble("height"));
        e.setBirthday(rs.getDate("birthday"));

        Department d = new Department();
        d.setId(rs.getInt("dept_id"));
        d.setName(rs.getString("dept_name"));
        d.setLoc(rs.getString("loc"));
        e.setDepartment(d);

        return e;
    }
}
